<template>
  <view class="input-bg">
    <view class="card-container">
      <textarea v-model="inputText" class="hidden-input" placeholder="请输入要生成的文字" @input="onInput" @focus="onFocus" @blur="onBlur" />
      <view class="card-text" v-if="inputText || !isFocus">{{ inputText || '请输入要生成的文字' }}</view>
    </view>
    <button type="primary" class="next-btn" @click="goNext">下一步</button>
  </view>
</template>

<script>
export default {
  data() {
    return { inputText: '', isFocus: false }
  },
  methods: {
    onInput(e) {
      this.inputText = e.detail.value
    },
    onFocus() {
      this.isFocus = true
    },
    onBlur() {
      this.isFocus = false
    },
    goNext() {
      if (!this.inputText) {
        uni.showToast({ title: '请输入文字', icon: 'none' })
        return
      }
      uni.navigateTo({
        url: '/pages/text-image-preview/text-image-preview?text=' + encodeURIComponent(this.inputText)
      })
    }
  }
}
</script>

<style scoped>
.input-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3e6fd 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 60rpx;
}
.card-container {
  width: 90vw;
  height: 60vh;
  background: #fff;
  border-radius: 32rpx;
  box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 60rpx;
  position: relative;
}
.hidden-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}
.card-text {
  font-size: 44rpx;
  color: #666;
  text-align: center;
  word-break: break-all;
  white-space: pre-line;
  width: 80vw;
  min-height: 100rpx;
  z-index: 1;
}
.next-btn {
  width: 60vw;
  background: #ff3b30;
  color: #fff;
  font-size: 32rpx;
  border-radius: 40rpx;
  padding: 16rpx 0;
  margin-top: auto;
  margin-bottom: 48rpx;
  display: block;
}
</style> 